/*
 * @(#) ComboBoxServiceImpl.java 2010-10-21
 *
 * Copyright (c) 2010, Strong Technology. All Rights Reserved.
 * Strong Technology. CONFIDENTIAL
 */
package cn.strong.gweva.common.business.service.impl;

import java.util.ArrayList;
import java.util.List;

import cn.strong.gweva.common.business.entity.ComboBoxEntity;
import cn.strong.gweva.common.business.service.ComboBoxService;
import cn.strong.gweva.common.util.CodeBook;
import cn.strong.gweva.common.util.Constants4Method;
import cn.strong.gweva.common.util.CodeBook.ATTENDANCE_STATUS;
import cn.strong.gweva.common.util.CodeBook.RANGE_TYPE;


/**
 * 下拉框检索Service
 * 
 * @author lilanfei
 * @version 1.0
 * @since 2011-06-02
 */
public class ComboBoxServiceImpl extends AbstractServiceImpl implements ComboBoxService
{
	
	/**
	 * 根据用户角色，获取角色列表
	 * 
	 * @param userRoleId 用户角色
	 * @return
	 * @throws Exception
	 */
	public List<ComboBoxEntity> searchRoleByRight(Integer userRoleId) throws Exception
	{
		List<ComboBoxEntity> roleList = new ArrayList<ComboBoxEntity>();
		
		if (userRoleId != null)
		{
			ComboBoxEntity temp = null;
			if (CodeBook.ROLE.SADMIN.getCode().compareTo(userRoleId) == 0
					|| CodeBook.ROLE.NADMIN.getCode().compareTo(userRoleId) == 0)
			{
				temp = new ComboBoxEntity(String.valueOf(CodeBook.ROLE.NUSER.getCode()), CodeBook.ROLE.NUSER.getName());
				roleList.add(temp);
				temp = new ComboBoxEntity(String.valueOf(CodeBook.ROLE.NADMIN.getCode()), CodeBook.ROLE.NADMIN.getName());
				roleList.add(temp);
			}
		}
		
		return roleList;
	}

	/**
	 * 检索岗位列表.
	 * 
	 * @return 岗位列表
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<ComboBoxEntity> searchJobList() throws Exception
	{
		return this.getCommonDao().searchList(Constants4Method.COMBOBOX_SEARCH_JOB_LIST, null);
	}
	


	/**
	 * 检索岗位考核项目列表.
	 * 
	 * @param jobId 岗位ID
	 * @return 岗位考核项目列表
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<ComboBoxEntity> searchJobItemList(Integer jobId) throws Exception
	{
		return this.getCommonDao().searchList(Constants4Method.COMBOBOX_SEARCH_JOB_ITEM_LIST, jobId);
	}

	/**
	 * 获取出勤状态列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public List<ComboBoxEntity> searchAttendanceStatusList() throws Exception
	{
		List<ComboBoxEntity> list = new ArrayList<ComboBoxEntity>();
		
		ComboBoxEntity temp = null;
		
		for (ATTENDANCE_STATUS status : ATTENDANCE_STATUS.values()) {
			temp = new ComboBoxEntity(status.getCode(), status.getName());
			list.add(temp);
		}
		
		return list;
	}
	
	/**
	 * 获取公共考核项目列表。
	 * 
	 * @return 公共考核项目列表
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<ComboBoxEntity> searchPublicItemList() throws Exception
	{
		return this.getCommonDao().searchList(Constants4Method.COMBOBOX_SEARCH_PUBLIC_ITEM_LIST, null);
	}
	
	/**
	 * 根据公共考核项目，获取公共考核规则列表。
	 * 
	 * @return 公共考核项目列表
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<ComboBoxEntity> searchPublicRuleList(Integer itemId) throws Exception
	{
		return this.getCommonDao().searchList(Constants4Method.COMBOBOX_SEARCH_PUBLIC_RULE_LIST_BY_ITEM, itemId);
	}

	/**
	 * 获取工作年限范围列表
	 * 
	 * @return
	 * @throws Exception
	 */
	public List<ComboBoxEntity> searchRangeTypeList() throws Exception
	{
		List<ComboBoxEntity> list = new ArrayList<ComboBoxEntity>();
		
		ComboBoxEntity temp = null;
		
		for (RANGE_TYPE status : RANGE_TYPE.values()) {
			temp = new ComboBoxEntity(String.valueOf(status.getCode()), status.getName());
			list.add(temp);
		}
		
		return list;
	}
	
}
